package com.tyut.web.controller.system;

import com.tyut.common.annotation.Log;
import com.tyut.common.core.controller.BaseController;
import com.tyut.common.core.domain.AjaxResult;
import com.tyut.common.core.page.TableDataInfo;
import com.tyut.common.enums.BusinessType;
import com.tyut.common.utils.poi.ExcelUtil;

import com.tyut.system.domain.TyutStudent;
import com.tyut.system.service.ITyutStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 实验室学生信息Controller
 * 
 * @author ruoyi
 * @date 2023-11-20
 */
@RestController
@RequestMapping("/person/tyutstudent")
public class TyutStudentController extends BaseController
{
    @Autowired
    private ITyutStudentService tyutStudentService;

    /**
     * 查询实验室学生信息列表
     */
    @PreAuthorize("@ss.hasPermi('person:tyutstudent:list')")
    @GetMapping("/list")
    public TableDataInfo list(TyutStudent tyutStudent)
    {
        startPage();
        List<TyutStudent> list = tyutStudentService.selectTyutStudentList(tyutStudent);
        return getDataTable(list);
    }

    /**
     * 导出实验室学生信息列表
     */
    @PreAuthorize("@ss.hasPermi('person:tyutstudent:export')")
    @Log(title = "实验室学生信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TyutStudent tyutStudent)
    {
        List<TyutStudent> list = tyutStudentService.selectTyutStudentList(tyutStudent);
        ExcelUtil<TyutStudent> util = new ExcelUtil<TyutStudent>(TyutStudent.class);
        util.exportExcel(response, list, "实验室学生信息数据");
    }

    /**
     * 获取实验室学生信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('person:tyutstudent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tyutStudentService.selectTyutStudentById(id));
    }

    /**
     * 新增实验室学生信息
     */
    @PreAuthorize("@ss.hasPermi('person:tyutstudent:add')")
    @Log(title = "实验室学生信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TyutStudent tyutStudent)
    {
        return toAjax(tyutStudentService.insertTyutStudent(tyutStudent));
    }

    /**
     * 修改实验室学生信息
     */
    @PreAuthorize("@ss.hasPermi('person:tyutstudent:edit')")
    @Log(title = "实验室学生信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TyutStudent tyutStudent)
    {
        return toAjax(tyutStudentService.updateTyutStudent(tyutStudent));
    }

    /**
     * 删除实验室学生信息
     */
    @PreAuthorize("@ss.hasPermi('person:tyutstudent:remove')")
    @Log(title = "实验室学生信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tyutStudentService.deleteTyutStudentByIds(ids));
    }
}
